<?php


class Pastebin
{

	protected $code;
	protected $format;
	protected $expire_date;
	protected $private;
	protected $name;
	protected $email;
	protected $subdomain;
	protected $result_url;
	
	
					
	function __construct($code, $format='text', $expire_date='N', $private=0, $name='', $email='', $subdomain=''){

		$this->code = $code;
		$this->format = $format;
		$this->expire_date = $expire_date;
		$this->private = $private;
		$this->name = $name;
		$this->email = $email;
		$this->subdomain = $subdomain;	
	
		$this->sendByPost($this->code, $this->format, $this->expire_date, $this->private, $this->name, $this->email, $this->subdomain);
	}

	private function sendByPost($code, $format, $expire_date, $private, $name, $email, $subdomain){
		
		$ch = curl_init("http://pastebin.com/api_public.php");
		
		curl_setopt ($ch, CURLOPT_POST, true);

		curl_setopt ($ch, CURLOPT_POSTFIELDS, "paste_code=".$code."&paste_format=".$format."&paste_expire_date=".$expire_date."&paste_private=".$private."&paste_name=".$name."&paste_email=".$email."&paste_subdomain=".$subdomain."&submit=submit");
		
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_VERBOSE, true);
		//curl_setopt($ch, CURLOPT_NOBODY, false);
		
		$this->result_url = curl_exec($ch);
		
		curl_close($ch);
		
		echo $this->result_url;
		 
		
	}
	
	
	public function modifyCode($url){ 
		
		$ch = curl_init($url);
		
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_VERBOSE, true);
		//curl_setopt($ch, CURLOPT_NOBODY, false);
		
		$result = curl_exec($ch);
		
		curl_close($ch);
		
		echo preg_replace('#^(.*)<pre>(.*)</pre>(.*)$#isU', '$2', $result);
		
	}
	
	//http://pastebin.com/embed_iframe.php?i=dGXC04vw
	//http://pastebin.com/raw.php?i=dGXC04vw
		
	//Check data type from arguments
}

$paste_code = new Pastebin('a{color: black;}');



?>